<?php

/**
 * This is the model class for table "organisasi".
 *
 * The followings are the available columns in table 'organisasi':
 * @property string $kode_org
 * @property string $nama_org
 * @property string $jenis_pem
 * @property string $nama_dinas
 * @property string $nama_pnd
 * @property string $alamat_dinas
 * @property string $nama_kab
 * @property string $ibu_kota
 * @property string $kode_rekang
 * @property string $perda
 * @property string $thn_perda
 * @property string $no_sk
 * @property string $tgl_sk
 */
class Organisasi extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'organisasi';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('kode_org', 'length', 'max'=>2),
			array('nama_org, perda', 'length', 'max'=>50),
			array('jenis_pem, kode_rekang, no_sk', 'length', 'max'=>35),
			array('nama_dinas', 'length', 'max'=>75),
			array('nama_pnd, ibu_kota', 'length', 'max'=>15),
			array('alamat_dinas', 'length', 'max'=>100),
			array('nama_kab', 'length', 'max'=>25),
			array('thn_perda', 'length', 'max'=>4),
			array('tgl_sk', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('kode_org, nama_org, jenis_pem, nama_dinas, nama_pnd, alamat_dinas, nama_kab, ibu_kota, kode_rekang, perda, thn_perda, no_sk, tgl_sk', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'kode_org' => 'Kode Org',
			'nama_org' => 'Nama Org',
			'jenis_pem' => 'Jenis Pem',
			'nama_dinas' => 'Nama Dinas',
			'nama_pnd' => 'Nama Pnd',
			'alamat_dinas' => 'Alamat Dinas',
			'nama_kab' => 'Nama Kab',
			'ibu_kota' => 'Ibu Kota',
			'kode_rekang' => 'Kode Rekang',
			'perda' => 'Perda',
			'thn_perda' => 'Thn Perda',
			'no_sk' => 'No Sk',
			'tgl_sk' => 'Tgl Sk',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('kode_org',$this->kode_org,true);
		$criteria->compare('nama_org',$this->nama_org,true);
		$criteria->compare('jenis_pem',$this->jenis_pem,true);
		$criteria->compare('nama_dinas',$this->nama_dinas,true);
		$criteria->compare('nama_pnd',$this->nama_pnd,true);
		$criteria->compare('alamat_dinas',$this->alamat_dinas,true);
		$criteria->compare('nama_kab',$this->nama_kab,true);
		$criteria->compare('ibu_kota',$this->ibu_kota,true);
		$criteria->compare('kode_rekang',$this->kode_rekang,true);
		$criteria->compare('perda',$this->perda,true);
		$criteria->compare('thn_perda',$this->thn_perda,true);
		$criteria->compare('no_sk',$this->no_sk,true);
		$criteria->compare('tgl_sk',$this->tgl_sk,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Organisasi the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
